const express = require("express");
const { createServer } = require("http");
const { Server } = require("socket.io");
import cors from "cors";

const app = express();
app.use(cors());
const httpServer = createServer(app);
const io = new Server(httpServer, { /* options */ });

io.on("connection", (socket) => {
    // ...
   socket.on("message", (data) => {
        console.log(data);
        io.emit("message", data);
   })
    console.log('a user connected');

});

httpServer.listen(3000);